home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 003 / dbaseacc.arc / REVIEW.PRG < prev    next >
Encoding:
Text File  |  1979-12-31  |  8.5 KB  |  337 lines

  1.           ********** REVIEW.CMD FILE **********
  2. * This is used to list entries in any .DBF file.  The database must be named in
  3. * the command file calling the procedure.  Records may be listed conditionally,
  4. * with or without the record numbers.
  5. *      Records are listed in groups of 10 with a line space between each group.
  6. * Processing can be continuous, or can stop after every group of 10.
  7. *      The listing can start on a specified record number.
  8. *      The files can be re-listed as many times as desired.
  9. *      Printing is optional.  The "CHR(X)" commands are for a Diablo 1650
  10. * printer.
  11. ***********************************************************
  12.  
  13. STORE 'Y' TO Reviewing
  14. DO WHILE !(Reviewing)='Y'
  15.    COPY STRUCTURE EXTENDED TO Temp
  16.    GO BOTTOM
  17.    STORE STR(#,5) TO Last
  18.    ERASE
  19.    ?
  20.    ? 'The '+!(Database)+' database has '-Last+' entries.  They will be shown'
  21.    ? 'in groups of 10 records, 50 records to a page if printed.'
  22.    ? 'Enter new values for defaults or press <Return>:'
  23.    ?
  24.    ? '*** DISPLAY [Field list] [FOR <expression>] [OFF] ***'
  25.    ?
  26.    STORE  1 TO First
  27.    STORE  1 TO PageCnt
  28.    STORE VAL(Last) TO RecoCnt
  29.    STORE 'N' TO Pause
  30.    STORE 'N' TO Partial
  31.    STORE 'N' TO Conditions
  32.    STORE 'N' TO Tally
  33.    STORE 'C' TO Changing
  34.    DO WHILE !(Changing) = 'C'
  35.       @  8,10 SAY 'START ON RECORD NUMBER ' GET First
  36.       @  9,10 SAY ' STOP ON RECORD NUMBER ' GET RecoCnt
  37.       @ 10,10 SAY ' START PAGE NUMBERS ON ' GET PageCnt
  38.       @ 11,10 SAY 'PAUSE EVERY 10 RECORDS ' GET Pause
  39.       @ 12,10 SAY '  SHOW SELECTED FIELDS ' GET Partial
  40.       @ 13,10 SAY 'DISPLAY FOR EXPRESSION ' GET Conditions
  41.       @ 14,10 SAY '   SHOW RECORD NUMBERS ' GET Tally
  42.  
  43.       ?
  44.       ? '     C to CHANGE the defaults,'
  45.       ? '    <Return> to continue.'
  46.       WAIT TO Changing
  47.  
  48.       IF !(Changing) = 'C'
  49.          * Clear to end of screen on ADM-31
  50.   @ 15,0 SAY CHR(27)+CHR(121)
  51.   READ
  52.       ELSE
  53.   IF First > VAL(Last) .OR. First <= 0 .OR. RecoCnt > VAL(Last);
  54.              .OR. RecoCnt <= 0
  55.      @ 15,0  SAY CHR(27)+CHR(121)
  56.      @ 16,0  SAY 'Sorry, wrong number: '-!(Database)+' contains '+;
  57.           'records 1 through'+Last+'.'
  58.      ? '<Return> to correct your entry.'
  59.             WAIT
  60.      @ 15,0 SAY CHR(27)+CHR(121)
  61.      STORE 'C' TO Changing
  62.      STORE 1 TO First
  63.      STORE VAL(Last) TO RecoCnt
  64.          ENDIF
  65.  
  66.          ENDIF
  67.          * Clears to end of screen on ADM-31
  68.          @ 15,0 SAY CHR(27)+CHR(121)
  69.       ENDDO
  70.       ?
  71.       ?
  72.       ?
  73.       ?
  74.       ?
  75.       ?
  76.       ?
  77.       ?
  78.       ?
  79.       ?
  80.       ?
  81.       ?
  82.       ?
  83.       ?
  84.       IF !(Partial)+ 'Y'
  85.      @ 11,0  SAY CHR(27)+CHR(121)
  86.      @ 11,0 SAY 'The '+!(Database)+' database consists of these FIELDS:'
  87.      USE Temp
  88.      ?
  89.      STORE ' ' TO Choices
  90.      DO WHILE .NOT. EOF
  91.         STORE Choices+TRIM(Field:Name)+', ' TO Choices
  92.         SKIP
  93.      ENDDO
  94.      STORE $(Choices,2,LEN(Choices)-3) TO Choices
  95.          STORE 'Y' TO Unfinished
  96.   DO WHILE !(Unfinished) = 'Y'
  97.      @ 13, 0 SAY Choices
  98.  
  99.      USE &Database
  100.      ? 'List FIELDS to display (<return> to shown all).'
  101.      ?
  102.      ACCEPT '        DISPLAY ' TO Partial
  103.      STORE !(Partial) TO Partial
  104.      STORE Partial TO String
  105.      STORE LEN(String) TO Size
  106.  
  107.      IF Size =0 .OR. (Size=1 .AND. Partial=' ')
  108.         STORE CHR(0) TO Partial
  109.         STORE 'N' TO Unfinished
  110.      ELSE
  111.         ?
  112.         ? 'Want to change it (Y or N)?'
  113.         WAIT TO Unfinished
  114.         IF !(Unfinished) = 'Y'
  115.            @ 12, 0 SAY CHR(27) + CHR(121)
  116.            ELSE
  117.            @ 10,0 SAY CHR(27) + CHR(121)
  118.            ? '*** Checking fields ['+Partials+'] : '
  119.            ?
  120.            STORE 0 TO F
  121.     STORE 0 TO Counter
  122.     DO WHILE Size >0
  123.        STORE Counter + 1 to Counter
  124.        ?? ' *'+STR(Counter,2)
  125.        STORE @(',', String) TO Mark
  126.        IF Mark = 1 .OR. Mark = Size
  127.    ? 'Uh, oh--trouble:  comma cannot be at the ';
  128.                    +'start or end of a list of values.'
  129.  
  130.        ? '<Return> and try again.'
  131.        STORE 0 TO Size
  132.        STORE 'Y' TO Unfinished
  133.        WAIT
  134.                   ELSE
  135.        IF Mark > 0
  136.    STORE (Mark - 1) TO Size
  137.        ENDIF
  138.  
  139.        STORE T TO Blank
  140.        STORE 1 TO Start
  141.        DO WHILE Blank .AND> (.NOT. Start > Size)
  142.    IF $(String, Start, 1)=' '
  143.       STORE (Start + 1) TO Start
  144.    ELSE
  145.       STORE (.NOT> Blank) TO Blank
  146.    ENDIF
  147.                      ENDDO
  148.  
  149.        IF Start > Size
  150.    ? 'How on earth can I find a blank field?'
  151.    ? '<Return> and try again.'
  152.    STORE 0 TO Size
  153.    STORE 'Y" TO Unfinished
  154.    WAIT
  155.        ELSE
  156.    STORE (F + 1) TO F
  157.    IF F < 10
  158.       STORE STR(F,1) TO Suffix
  159.    ELSE
  160.       STORE STR(F,2) TO Suffix
  161.    ENDIF
  162.    STORE 'FIELD'+Suffix TO Field
  163.    STORE TRIM($(String,Start,(Size-Start+1) )) TO &Field
  164.  
  165.    IF Mark > 0
  166.       STORE TRIM($(String, (Size + 2))) TO String
  167.       STORE LEN(String) TO Size
  168.    ELSE
  169.       STORE 'N' TO Unfinished
  170.       STORE 0 TO Size
  171.    ENDIF
  172.                      ENDIF
  173.                   ENDIF
  174.                ENDDO
  175.             ENDIF
  176.          ENDIF
  177.       ENDDO
  178.  
  179.       IF LEN(Partial) > 0
  180.    *      DO headings
  181.          ? "WE'D DO THE HEADINGS HERE."
  182.   WAIT
  183.       ENDIF
  184.  
  185.    ELSE
  186.       STORE CHR(0) TO Partial
  187.    ENDIF
  188.  
  189.    IF !(Conditions) = 'Y'
  190.       STORE 'Y' TO Unfinished
  191.       DO WHILE !(Unfinished) = 'Y'
  192.          @ 11, 0 SAY CHR(27)+CHR(121)
  193.   @ 11, 0 SAY 'Specify the EXPRESSION or <Return> to skip.'
  194.  
  195.       ?
  196.       ? 'DISPLAY &Partial FOR '
  197.       ACCEPT TO Expression
  198.       ?
  199.       ? 'Do you want to change the expression (Y or N)?'
  200.       WAIT TO Unfinished
  201.    ENDDO
  202.  
  203.    IF Expression > '
  204.       STORE 'FOR '+ Expression TO Conditions
  205.    ELSE
  206.       STORE CHR(0) TO Conditions
  207.    ENDIF
  208. ELSE
  209.    STORE CHR(0) TO Conditions
  210. ENDIF
  211.  
  212. IF!(Tally) <> 'Y'
  213.    STORE 'OFF' TO Tally
  214. ELSE
  215.    STORE CHR(0) TO Tally
  216. ENDIF
  217.  
  218. STORE [DISPLAY Next 1 &Partial &Conditions &Tally] TO Command
  219. @ 11, 0 SAY CHR(27)+CHR(121)
  220. @ 11, 0 SAY '***  '+[DISPLAY &Partial &Conditions &Tally]+' ***'
  221. ?
  222. ? 'is the command that will be performed on the '+!(Database)+' database.'
  223. ? '      C to CHANGE it,'
  224. ? '      Q to QUIT with no action,'
  225. ? '   <Return> to review the database.'
  226. WAIT TO Abort
  227.  
  228. IF !(Abort) = 'Q'
  229.    STORE CHR(0) TO Reviewing
  230. ELSE
  231.    IF !(Abort) <> 'C'
  232.       ERASE
  233.       ? 'Enter a one-line heading or press <Return> to skip.'
  234.       ACCEPT TO Message
  235.       STORE !(Message) TO Message
  236.       ?
  237.       STORE 0 TO Count
  238.       STORE 0 TO PageMark
  239.       STORE STR(First,5) TO Number
  240.       GO &Number
  241.  
  242.       ERASE
  243.       ? 'Do you want to print the listing now (Y or N)?'
  244.       ACCEPT TO Hardcopy
  245.  
  246.       IF !(Hardcopy)='Y'
  247.          SET PRINT ON
  248.          DO RevMrgn
  249.       ENDIF
  250.  
  251.       ERASE
  252.       ? Message
  253.       ? 'Page '+ STR(PageCnt,3)
  254.  
  255.       IF Tally = 'OFF'
  256.           ?? ' starts on Record #'-STR(#,5)
  257.           ?
  258.           IF .NOT.( Partial > ' ' .OR. Conditions > ' ')
  259.  
  260.    DO RevHdr
  261.        ENDIF
  262.    ENDIF
  263.    ?
  264.    DO WHILE .NOT. EOF .AND. # <= RecoCnt
  265.       &Command
  266.  
  267.       IF !(Conditions) > CHR(0)
  268.          IF &Expression
  269.             STORE (Count + 1) TO Count
  270.          ENDIF
  271.       ELSE
  272.         STORE (Count + 1) TO Count
  273.       ENDIF
  274.       SKIP
  275.  
  276.       IF Count=10
  277.          STORE 0 TO Count
  278.          * Inserts a space every ten records, then waits.  The printer
  279.          * is turned off so that "WAIT" does not print on the hardcopy.
  280.          ?
  281.   SET PRINT OFF
  282.   IF !(Pause) = 'Y'
  283.      WAIT
  284.   ENDIF
  285.  
  286.   IF !(Hardcopy) = 'Y'
  287.      SET PRINT ON
  288.   ENDIF
  289.  
  290.   * The following routine prints 50 entries to a page,
  291.          * then moves to the next page and prints a heading
  292.  
  293.   STORE (PageMark + 1) TO PageMark
  294.   IF PageMark = 5
  295.      ? CHR(12)
  296.      STORE (PageCnt + 1) TO PageCnt
  297.  
  298.      IF INT(PageCnt/7) = PageCnt/7
  299.            ?
  300.      ENDIF
  301.  
  302.      ? Message
  303.      ? 'Page '+STR(PageCnt,3)
  304.  
  305.      IF Tally = 'OFF'
  306.         ?? ' starts on Record #'-STR(#,5)
  307.         ?
  308.         IF .NOT.( Partial > ' ' .OR. Conditions > ' ')
  309.     DO RevHdr
  310.         ENDIF
  311.      ENDIF
  312.      ?
  313.      STORE 0 TO PageMark
  314.   ENDIF
  315.       ENDIF
  316.    ENDDO
  317.  
  318.    * Formfeed on Diablo 1650 printer
  319.    ? CHR(12)
  320.    SET PRINT OFF
  321.    SET RAW ON
  322.    SET MARGIN TO 38
  323.    ? 'Do you want to see the '+!(Database)+' again (Y or N)?'
  324.  
  325.            WAIT TO Reviewing
  326.         ELSE
  327.            STORE 'Y' TO Reviewing
  328.  ENDIF
  329.      ENDIF
  330.      ?
  331.   ENDDO Reviewing
  332.  
  333.   USE
  334.   DELETE FILE Temp
  335.   RELEASE ALL
  336.   RETURN
  337.